package com.zelic.znn.functions;

/**
 * @since 17/07/2011
 * @author zelic
 * Filename: SigmoidMethod.java
 * Description: sigmoid method
 */

/**
 * Sigmoid method is used to generate real value from 0 to 1
 * @author zelic
 */
public class SigmoidFunction implements OutputFunction{
    
    /**
     * Calculate output with sigmoid method
     * @param net:array of nets of units
     * @return output array 
     */
    @Override
    public double[] calculateOutputArray(double[] net){
        int length = net.length;
        double[] result = new double[length];
        for (int i=0;i<length;i++){
            result[i] = (1/(1+Math.exp(-net[i])));
        }
        return result;
    }
    
    /**
     * Get Derivation at a specific number of Sigmoid function
     * @param number : the point get derivation
     * @return derivation in double
     */
    @Override
    public double getDerivation(double number){
        return number*(1-number);
    }
            
            
}
